<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/10/5
  Time: 20:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<html>
  <head>
    <base href="${pageContext.request.contextPath}/">
    <title>个人简历信息列表</title>
    <style>
      .div{
        margin-left: 450px;
      }
    </style>
    <script src="jq/jquery.js"></script>
  </head>
  <body>
  <h1 align="center">个人简历信息列表</h1>
  <div align="center">
    <form action="ListServlet" method="post">
      性别：<input type="radio" name="condition" value="男">男
      <input type="radio" name="condition" value="女">女
      <input type="radio" name="condition" value="全部" checked>全部
      <input style="margin-left: 20px" type="submit" value="查询">
      <input style="margin-left: 50px" type="button" onclick="location.href='add.jsp'" value="新增个人简历信息">
    </form>
  </div>
  <br>
  <div class="div">
    <form action="">
      <table border="1px" id="table">
        <tr align="center">
          <th>姓名</th>
          <th>性别</th>
          <th>籍贯地址</th>
          <th>出生时间</th>
          <th>联系电话</th>
          <th>毕业学校</th>
          <th>简历状态</th>
          <th>操作</th>
        </tr>
        <c:forEach items="${sessionScope.list}" var="resume" >
          <tr align="center">
            <td>${resume.userName}</td>
            <td>${resume.sex}</td>
            <td>${resume.address}</td>
            <td>${resume.birth}</td>
            <td>${resume.telephone}</td>
            <td>${resume.school}</td>
            <c:if test="${resume.status == 0}">
              <td>保密</td>
            </c:if>
            <c:if test="${resume.status == 1}">
              <td>公开</td>
            </c:if>
            <td><a href="javascript:void(0)" onclick="remove('${resume.id}')">删除</a></td>
          </tr>
        </c:forEach>
      </table>
    </form>
  </div>
  <script>
    function remove(id) {
      if(confirm("确认删除吗？")){
        $.getJSON(
                'DeleteServlet',
                {id:id},
                function (data) {
                  if(data){
                    alert("删除成功！");
                    location.href='ListServlet'
                  }else{
                    alert("删除失败！");
                  }
                }
        )
      }
    }
  </script>
  </body>
</html>
